home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / C / Blitter / Rectangles.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-15  |  1.4 KB  |  53 lines

  1. /* Dice: 1> dcc -l0 -mD dpk.o tags.o Rectangles.c -o Rectangles
  2. **
  3. ** Draws different rectangles at random positions.
  4. */
  5.  
  6. #include <proto/dpkernel.h>
  7.  
  8. BYTE *ProgName      = "Rectangles";
  9. BYTE *ProgAuthor    = "Paul Manias";
  10. BYTE *ProgDate      = "July 1998";
  11. BYTE *ProgCopyright = "DreamWorld Productions (c) 1998.  Freely distributable.";
  12. BYTE *ProgShort     = "Draws different rectangles at random positions.";
  13.  
  14. LONG Palette[] = {
  15.   ID_PALETTE, 16,
  16.   0x000000,0xff0000,0x00ff00,0x0000ff,0xffff00,0xff00ff,0x00ffff,0x555555,
  17.   0xaaaaaa,0xffffff,0xff3456,0x6543ff,0xffaadd,0x29ff55,0x96f92a,0x89fa92
  18. };
  19.  
  20. void main(void)
  21. {
  22.   struct GScreen *Screen;
  23.   struct JoyData *JoyData;
  24.   WORD   sx,sy,width,height;
  25.  
  26.   if (Screen = InitTags(NULL,
  27.       TAGS_SCREEN, NULL,
  28.         GSA_BitmapTags, NULL,
  29.         BMA_Palette,    Palette,
  30.         TAGEND,         NULL,
  31.       TAGEND)) {
  32.  
  33.      if (JoyData = Init(Get(ID_JOYDATA),NULL)) {
  34.  
  35.         Display(Screen);
  36.  
  37.         do {
  38.           Query(JoyData);
  39.           sx = FastRandom(Screen->Width)-50;
  40.           sy = FastRandom(Screen->Height)-50;
  41.           width  = FastRandom(Screen->Width)+1;
  42.           height = FastRandom(Screen->Height)+1;
  43.           SetRGBPen(Screen->Bitmap,Palette[FastRandom(15)+3]);
  44.           PenRect(Screen->Bitmap,sx,sy,width,height,FastRandom(2));
  45.         } while (!(JoyData->Buttons & JD_LMB));
  46.  
  47.      Free(JoyData);
  48.      }
  49.   Free(Screen);
  50.   }
  51. }
  52.  
  53.